<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加权限</title>
	<#include "./comm/meta-base.ftl" />
	<#include "./comm/meta-easyui.ftl" />
	<#include "./comm/meta-comm.ftl" />
</head>
<body>
		
<form id="data_form" role="form" class="page-form"   method="post" >
 	<!--表单块-->
	<div class="form-title">权限基础信息</div>
	<div class="row">
		
		<div class="form-group col-sm-6 ">
			<label class="col-sm-4 fm-label">权限名称</label>
			<div class="col-sm-8 fm-control">
				<input type="text" name="name" class="form-control easyui-validatebox" data-options="required:true" />
				<input type="hidden" name="privilegePid" value="${parentPO.privilegeId}" />
			</div>
		</div>
		
		<div class="form-group col-sm-6">
			<label class="col-sm-4 fm-label">权限图标</label>
			<div class="col-sm-6 fm-control" style="">
				<span class="input-icon icon-left">
					<input type="text" name="icon" class="form-control easyui-validatebox" data-options="required:true"  value="fa-align-justify" onchange="changeIcon(this)" />
					<i class="fa fa-align-justify"></i>
				</span>

			</div>
			<label class="col-sm-2">
				<a href="${basePath}/static-server/plugs/beyondadmin/font-awesome.html" target="_black" >图标</a>
			</label>
		</div>
	
	</div>
	<div class="row">
		<div class="form-group col-sm-12">
			<label class="col-sm-2 fm-label">程序代码</label>
			<div class="col-sm-10 fm-control" >
				<input type="text" name="programCode" onchange="changeProgramCode(this)" class="form-control easyui-validatebox" data-options="" />
			</div>
		</div>
	</div>
	
	
	<div class="form-title">部署信息</div>
	<div class="row">
		
		<div class="form-group col-sm-6 ">
			<label class="col-sm-4 fm-label">所属应用系统 :</label>
			<div class="col-sm-8 fm-control">
				<label class="fm-label">${upmsAppSystemPO.name}</label>
				<input type="hidden" name="appSystemId" value="${upmsAppSystemPO.appSystemId}" />
			</div>
		</div>
		
		<div class="form-group col-sm-6">
			<label class="col-sm-4 fm-label">所属应用</label>
			<div class="col-sm-8 fm-control" style="">
				<select class="easyui-combobox" name="appId">
				<#list upmsAppPOList as upmsAppPO>
					<option value="${upmsAppPO.appId}">${upmsAppPO.name}</option>
				</#list>
      			</select>
			</div>
		</div>
	
	</div>
	
	
	
	<!--隐藏-->
	<div style="display:none">
	
	<div class="form-title hidden" id="opt-tit">操作权限</div>
	<div class="row hidden" id="opt-row">
		<div class="buttons-preview" style="border:0px;" >
			<a class="btn btn-default  btn-sm" 
            	href="javascript:addOperate()"><i class="fa fa-plus"></i>添加操作权限</a>
		</div>
	   
		<table class="table   table-bordered ">
			<thead>
				<tr>
					<th width="300">操作权限名称</th>
					<th width="400">操作权限编码</th>
					<th >操作</th>
				</tr>
			</thead>
			<tbody id="app-tbody">
				<#list standardUpmsOperatePOList as standardUpmsOperatePO>
					<tr>
						<td>${standardUpmsOperatePO.name}</td>
						<td>${standardUpmsOperatePO.code}</td>
						<td></td>
					</tr>
				</#list>
			</tbody>
		</table>
		
	</div>
	
	<!--隐藏-->
	</div>
	
    
    <!--表单操作按钮区-->
    <div class="but-row-bottom-shadow"></div>
    <div class="buts-row-bottom row ">
		<a href="javascript:submitForm();"  class="btn btn-success">
				<i class="fa fa-check"></i>提 交</a>
		<a href="javascript:closeWindow('添加权限');" class="btn btn-default">
				<i class="fa fa-times"></i>取 消</a>
	</div>
 </form>
</body>
</html>
<script type="text/javascript">
function changeProgramCode(obj){
	var $this=$(obj);
	if($this.val()!=""){
		$("#opt-row").removeClass("hidden");
		$("#opt-tit").removeClass("hidden");
	}else{
		$("#opt-row").addClass("hidden");
		$("#opt-tit").removeClass("hidden");
	}
	
}

//提交表单
function submitForm(){
	$("#data_form").form('submit', {
		url : '${basePath}/privilege/privilege-save',
		onSubmit: function (){
			showPageShade();//当提交时候，显示遮罩层
			if(!$(this).form('validate')){//页面验证
				hiddenPageShade();//未成功，隐藏遮罩层
				return false;
			}
			return true;
        },
		success : function(result) {
			hiddenPageShade();//成功后，隐藏遮罩层
			closeWindowRefrresh("添加权限");
		}
	});
}



function removeOperate(obj){
	var $this=$(obj);
	$this.parent().parent().remove();
	
}
function addOperate(){
	
	var html="<tr>"+
			"<td><input type=\"text\" name=\"operateNameArray\" class=\" form-control easyui-validatebox\" data-options=\"required:true\" style=\"height:28px;width:290px;\"/></td>"+
			"<td><input type=\"text\" name=\"operateCodeArray\" class=\"form-control easyui-validatebox\" data-options=\"required:true\"  style=\"height:28px;width:290px;\"/></td>"+
			"<td><a class=\"btn btn-danger btn-xs icon-only white\" onclick=\"removeOperate(this)\" href=\"javascript:void(0);\"><i class=\"fa fa-times \"></i></a></td>"+
		"</tr>";
	$("#app-tbody").append(html);
	$.parser.parse($("#app-tbody"));
	

	
}
function changeIcon(obj){
	var $this=$(obj);
	var $i=$this.next("i.fa");
	var cls="fa "+$this.val();
	$i.attr("class",cls);
}
</script>


